package com.gitee.mrj.aiboot.core.runner;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gitee.mrj.aiboot.core.model.AibootPost;
import com.gitee.mrj.aiboot.core.sf.generators.UIForm;
import com.gitee.mrj.aiboot.core.sf.schema.UiFormSchemaGenerator;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class ConfigRunner implements ApplicationRunner {

    private String str = "new String[0]";

    @Override
    public void run(ApplicationArguments args) throws JsonProcessingException {
//        SFSchema sfs = SchemaUtil.build(EruptPost.class);
//        System.out.println(sfs.toString());

//        List<Field> allFieldsList = ReflectionUtils.findAllAlainFields(EruptPost.class);
//        for (Field field : allFieldsList) {
//            AlainField alain = AnnotatedElementUtils.findMergedAnnotation(field, AlainField.class);
//            System.out.println(alain.title());
//        }
        ObjectMapper mapper = new ObjectMapper();
        UIForm uiForm = UiFormSchemaGenerator.generate(AibootPost.class);

        System.out.println(mapper.writeValueAsString(uiForm));
    }

}
